The best books to learn to think like a functional programmer

Why am I passionate about this?

I'm a programmer with a desire to constantly learn and improve. I have many years of experience in writing mission-critical software in highly event-driven areas such as FinTech and online auctions. Through interesting and challenging projects, I've always been fascinated by trying to generalize and abstract what it is that makes good code; so things like design patterns and best practices were just up my street. As I expanded this personal research, I found that functional programming provided many interesting techniques, but that many professionals in the industry were unaware of them. This is why I decided to show these techniques and their benefits to a wider audience through my book Functional Programming in C#.


I wrote...

Functional Programming in C#

By Enrico Buonanno,

Book cover of Functional Programming in C#

What is my book about?

Functional Programming in C# teaches you to apply functional thinking to real-world problems using the C# language. You'll start by learning the principles of functional programming and the language features that allow you to program functionally. As you explore the many practical examples, you'll learn the power of function composition, data flow programming, immutable data structures, and monadic composition with LINQ.

Shepherd is reader supported. When you buy books, we may earn an affiliate commission.

The books I picked & why

Book cover of Learn You A Haskell For Great Good

Enrico Buonanno Why did I love this book?

You may have got a taste of functional programming by learning some functional techniques in the language they use everyday, but if you want to deepen your knowledge, it's best to learn a functional language.

A multi-paradigm language like C# allows you to mix and match different techniques; a purely functional language, on the other hand, will force you to use the functional approach throughout—for example, by not allowing any state mutation at all.

The natural choice would be to learn Haskell, the functional language of reference and a lingua franca among functional programmers. Learning Haskell will allow you to take advantage of a wealth of literature on functional programming - books, blogs, talks, and so on - many of which have code samples in Haskell.

For this, I recommend you read Learn You a Haskell for Great Good by Miran Lipovaca. This book has been a favourite throughout the years, thanks to its conversational, no-nonsense approach, and the humorous sketches that lighten up the reading.

It assumes no prior knowledge of Haskell (the syntax can seem daunting at first, as it's so different from the popular C-derived languages), and gently guides you through the syntax and the ideas of functional programming. Another great feature of this book is that you can read it for free online although I do recommend you reward the author's work by buying a copy.

By Miran Lipovaca,

Why should I read it?

1 author picked Learn You A Haskell For Great Good as one of their favorite books, and they share why you should read it.

What is this book about?

It's all in the name: Learn You a Haskell for Great Good! is a hilarious, illustrated guide to this complex functional language. Packed with the author's original artwork, pop culture references, and most importantly, useful example code, this book teaches functional fundamentals in a way you never thought possible. You'll start with the kid stuff: basic syntax, recursion, types and type classes. Then once you've got the basics down, the real black belt master-class begins: you'll learn to use applicative functors, monads, zippers, and all the other mythical Haskell constructs you've only read about in storybooks. As you work your…


Book cover of Domain Modeling Made Functional: Tackle Software Complexity with Domain-Driven Design and F#

Enrico Buonanno Why did I love this book?

Many functional programming books concentrate on the detail of functional techniques (things like recursion or higher-order functions), often leaving open the gap between these techniques and their concrete application to solve everyday programming tasks.

This was one of the reasons I wrote my book, and one source of inspiration for me was the work of F# evangelist Scott Wlashin.

For many years, Scott has been showing how he applies functional thinking in his daily practice centered around e-commerce, through blog posts on his popular site and his talks at programming conferences. At popular request, he's organized these ideas into his book Domain Modelling Made Functional.

The examples are practical enough that every business application programmer will be able to relate to them, and his explanation of functional programming techniques and ideas is clear and rigorous. Although Scott encourages the adoption of F# (the functional-first language of the .NET family), these ideas are language agnostic and can be applied in many languages—including C#, which has been expanding its list of functional features with each release.

This means that you will benefit from reading Scott's book even if you're not using, don't know, and are not planning to use F#.

By Scott Wlaschin,

Why should I read it?

2 authors picked Domain Modeling Made Functional as one of their favorite books, and they share why you should read it.

What is this book about?

You want increased customer satisfaction, faster development cycles, and less wasted work. Domain-driven design (DDD) combined with functional programming is the innovative combo that will get you there. In this pragmatic, down-to-earth guide, you'll see how applying the core principles of functional programming can result in software designs that model real-world requirements both elegantly and concisely - often more so than an object-oriented approach. Practical examples in the open-source F# functional language, and examples from familiar business domains, show you how to apply these techniques to build software that is business-focused, flexible, and high quality. Domain-driven design is a well-established…


Book cover of Type-Driven Development with Idris

Enrico Buonanno Why did I love this book?

For many years I did not question the validity of the language I was using, focussing instead on becoming good at getting it to do what was needed. It never occurred to me that, say, the type system could be flawed, causing extra work and allowing unnecessary bugs to seep in.

But what if, instead of writing validation code, you could define your types in a way that makes it impossible to create an invalid instance? What if you could define state transitions in such a way that a state machine cannot transition into an invalid state? These are indeed some of the things the Idris language allows.

In his book Type-Driven Development with Idris, Edwin Brady takes you through both the ideas of type-driven development, and how they're enabled in Iris. Iris looks a lot like Haskell, but better. It even has a unique solution for the complex issue of combining different effects (something that in Haskell is done with the somewhat clunky monad transformers).

What surprised me about this book, was how approachable Edwin manages to make these somewhat complex issues. It's a readable book, regardless of your prior knowledge of the topic. Idris is still a very niche programming language, and you may never be able to use it in a commercial project.

Nonetheless, it's fascinating and enriching to know about it, and get an idea of what the programming languages of the future may have in store for us.

By Edwin Brady,

Why should I read it?

1 author picked Type-Driven Development with Idris as one of their favorite books, and they share why you should read it.

What is this book about?

DESCRIPTION

Types are often seen as a tool for checking errors, with the

programmer writing a complete program first and using the type

checker to detect errors. And while tests are used to show presence of

errors, they can only find errors that you explicitly test for. In typedriven

development, types become your tools for constructing

programs and, used appropriately, can show the absence of errors. And

you can express precise relationships between data, your assumptions

are explicit and checkable, and you can precisely state and verify

properties. Type-driven development lets users write extensible code,

create simple specifications very early…


Book cover of Elm in Action

Enrico Buonanno Why did I love this book?

If you're a C# programmer and have read or are interested in my book, there's a good chance you're working on a backend that supports a web application powered with JavaScript (or another language that compiles to JavaScript).

If you're interested in having more functional programming in your life, I recommend you learn Elm, a purely functional language that compiles to JavaScript.

To do this, I recommend Richard Feldman's Elm in Action, a book that takes you from zero to writing a web app in Elm.

The book teaches you everything you need to know to get started with Elm: 1) the syntax—it's a language of the ML family (like Haskell or F#) but its type system is simpler, and generally the language has been designed to be the most approachable functional language out there; 2) the Elm architecture—you write code that works within a framework, so you can write purely functional code (code that is deterministic and does not cause any side effects), while the framework takes care of performing the side effects; 3) how you can use Elm to manage a small part of an existing web app, so that you can get started experimenting in Elm in a working app, without the need for a cumbersome migration; 4) how to get Elm to communicate with JavaScript libraries you may have.

Richard is truly passionate about Elm, and has worked at NoRedInk along with Elm's creator Evan Czaplicki, so he's truly well placed to share the insights gathered by writing Elm code in large, real-world web applications.

By Richard Feldman,

Why should I read it?

1 author picked Elm in Action as one of their favorite books, and they share why you should read it.

What is this book about?

Elm is more than just a cutting-edge programming language, it's a chance to upgrade the way you think about building web applications. Once you get comfortable with Elm's refreshingly different approach to application development, you'll be working with a clean syntax, dependable libraries, and a delightful compiler that essentially eliminates runtime exceptions. Elm compiles to JavaScript, so your code runs in any browser, and Elm's best-in-class rendering speed will knock your socks off. Let's get started!

Elm in Action teaches you how to build well-designed, highly performant web applications using the Elm language. As you read, you'll follow an application…


Book cover of Seven Concurrency Models in Seven Weeks: When Threads Unravel

Enrico Buonanno Why did I love this book?

I think it's beyond dispute that concurrency is the most challenging area of programming.

Even fairly simple programs can become dauntingly complex once you introduce concurrency into the picture. For this reason, concurrency is definitely one area where even accomplished programmers should keep honing their skills.

Another difficulty is that there are different sorts of concurrency (parallelism, multi-threading, asynchrony), and different environments (in terms of latency, durability, etc) which all require different solutions.

Paul Butcher's Seven Concurrency Models in Seven Weeks helps you to make sense of this complexity by presenting different programming tasks along with the solution that most effectively tackles each task. It takes you from a demonstration of the use (and problems) of threads and locks - the most widespread, yet also the most low-level and error-prone approach to concurrent programming - to atoms - units that associate a constant identity with a mutable value - to actors, and so on.

The book is language agnostic, and uses a language that embraces the paradigm presented in each chapter. For example, locks are demonstrated in Java, atoms in Clojure, while code in the chapter on the actor model is in Elixir.

Reading this book will not only open your eyes to some applications of concurrency you may not be familiar with, it will also give you a good idea of what conceptual tools and programming frameworks are best suited to the concurrency issue you may be grappling with.

By Paul Butcher,

Why should I read it?

1 author picked Seven Concurrency Models in Seven Weeks as one of their favorite books, and they share why you should read it.

What is this book about?

Your software needs to leverage multiple cores, handle thousands of users and terabytes of data, and continue working in the face of both hardware and software failure. Concurrency and parallelism are the keys, and Seven Concurrency Models in Seven Weeks equips you for this new world. See how emerging technologies such as actors and functional programming address issues with traditional threads and locks development. Learn how to exploit the parallelism in your computer's GPU and leverage clusters of machines with MapReduce and Stream Processing. And do it all with the confidence that comes from using tools that help you write…


5 book lists we think you will like!

Interested in object-oriented programming, computer programming, and software engineering?

11,000+ authors have recommended their favorite books and what they love about them. Browse their picks for the best books about object-oriented programming, computer programming, and software engineering.

Object-Oriented Programming Explore 19 books about object-oriented programming
Computer Programming Explore 39 books about computer programming
Software Engineering Explore 25 books about software engineering